﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public abstract class BaseSingltonMono<T>  : MonoBehaviour where T : BaseSingltonMono<T> 
{
    //继承于MonoBehaviour的单例
   static private T _Singleton;

   static public T Singleton
    {
        get
        {
            if (_Singleton == null)
            {
                Debug.LogError(typeof(T).ToString() + "单例不存在!");
            }

            return (T)_Singleton;
        }
    }

    private void Awake()
    {
        _Singleton = (T)this;
        AwakeInit();
    }

    /// <summary>
    /// 实例初始化调用
    /// </summary>
    protected abstract void AwakeInit();
}
